package com.xc.videosample

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.widget.ViewPager2
import com.xc.videosample.databinding.ActivityViewPage2Binding

class ViewPage2Activity : FragmentActivity() {

    companion object {
        fun start(context: Context) {
            context.startActivity(Intent(context, ViewPage2Activity::class.java))
        }
    }

    lateinit var dataBinding: ActivityViewPage2Binding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        dataBinding =
            DataBindingUtil.setContentView(this, R.layout.activity_view_page2)
        val fragments = ArrayList<Fragment>()
        fragments.add(VideoPlayerFragment.newInstance(0))
        fragments.add(VideoPlayerFragment.newInstance(1))
        fragments.add(VideoPlayerFragment.newInstance(2))
        fragments.add(VideoPlayerFragment.newInstance(3))

        dataBinding.viewPage2.apply {
            orientation = ViewPager2.ORIENTATION_VERTICAL
            adapter = ViewPage2Adapter(this@ViewPage2Activity, fragments)
            currentItem = 0

        }
//        offscreenPageLimit = fragments.size

    }


    override fun onResume() {
        super.onResume()
    }

    override fun onPause() {
        super.onPause()
    }


}